package com.xiaoshuidi.cloud.module.member.controller.admin.activities;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.member.controller.admin.activities.vo.ActivitiesCreateVO;
import com.xiaoshuidi.cloud.module.member.controller.admin.activities.vo.ActivitiesDetailVO;
import com.xiaoshuidi.cloud.module.member.controller.admin.activities.vo.ActivityPageVO;
import com.xiaoshuidi.cloud.module.member.controller.admin.comment.vo.CommentPageVO;
import com.xiaoshuidi.cloud.module.member.controller.app.activities.vo.ActivitiesListVO;
import com.xiaoshuidi.cloud.module.member.controller.app.comment.vo.MemberCommentRespVO;
import com.xiaoshuidi.cloud.module.member.service.activities.MemberActivitiesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xiaoshuidi.cloud.module.member.enums.ApiConstants;
import javax.annotation.Resource;
import javax.validation.Valid;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 活动")
@RestController
@RequestMapping(ApiConstants.NAME+"/activities")
@Validated
public class MemberActivityController {
    @Resource
    private MemberActivitiesService memberActivitiesService;
    @PostMapping("/create")
    @Operation(summary = "创建活动")
    public CommonResult<Boolean> create(@Valid @RequestBody ActivitiesCreateVO createReqVO) {
        return success(memberActivitiesService.create(createReqVO));
    }

    @PostMapping("/get-page")
    @Operation(summary = "获得活动列表")
    public CommonResult<PageResult<ActivitiesListVO>> getPage(@Valid @RequestBody ActivityPageVO pageVO) {
        PageResult<ActivitiesListVO> pageResult = memberActivitiesService.getPage(pageVO);
        return success(pageResult);
    }

    @PostMapping("/get-by-id/{id}")
    @Operation(summary = "获得活动详情")
    public CommonResult<ActivitiesDetailVO> getById(@PathVariable("id") Long id) {
        return success(memberActivitiesService.getById(id));
    }


    @PostMapping("/edit")
    @Operation(summary = "编辑活动活动")
    public CommonResult<Boolean> edit(@Valid @RequestBody ActivitiesCreateVO createReqVO) {
        return success(memberActivitiesService.edit(createReqVO));
    }
}
